package com.sf.osms.dep.dao.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.dozer.Mapper;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.sf.novatar.base.dao.BaseBeanDao;
import com.sf.osms.dep.dao.IHandoverFileMapDao;
import com.sf.osms.dep.domain.HandoverFileMap;
/**
 * handover dao impl
 * @author 841245
 *
 */
@Repository
public class HandoverFileMapDaoImpl extends BaseBeanDao<Long,HandoverFileMap>  implements IHandoverFileMapDao {


	@Autowired
	private Mapper mapper;


	@Override
	public List<HandoverFileMap> queryHandOverFileMap(String countryCode,
			Long agentId, String network) {
		
		DetachedCriteria criteria = DetachedCriteria.forClass(HandoverFileMap.class);
		criteria.add(Restrictions.eq("countryCode", countryCode));
	
		criteria.add(Restrictions.eqOrIsNull("agentId", agentId));
		
		if (StringUtils.isEmpty(network)) {
			//空值或者空字符串都要要查出来，认为是相同的
			criteria.add(Restrictions.or(Restrictions.isNull("network"),Restrictions.eq("network", ""))); //Restrictions
		}else{
			criteria.add(Restrictions.eq("network", network));
		}
		
		List<HandoverFileMap> result = this.findBy(criteria);
		
		return result;
	}
	


}
